home *** CD-ROM | disk | FTP | other *** search
- //: C10:Funobj.cpp
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Static objects in functions
- #include <iostream>
- using namespace std;
-
- class X {
- int i;
- public:
- X(int ii = 0) : i(ii) {} // Default
- ~X() { cout << "X::~X()" << endl; }
- };
-
- void f() {
- static X x1(47);
- static X x2; // Default constructor required
- }
-
- int main() {
- f();
- } ///:~
-